<template>
  <AppView :title="title" :menu-list="testMenuListData">
    <div slot="content">
      <router-view/>
    </div>
  </AppView>
</template>

<script>
import AppView from "../../components/basic/AppView";
import caishen from "../../assets/image/caishen.png";

export default {
  name: 'Content',
  components: {
    AppView
  },
  data: function () {
    return {
      title: "banner",
      testMenuListData: {
        baseRoute: "content",
        menuList: [
        {
          title: "内容管理",
          icon: caishen,
          items: [
            {
              route: "banner",
              text: "轮播管理",
              default:true
            },
            {
              route: "artical",
              text: "文章管理"
            },
            {
              route: "opinion",
              text: "意见反馈"
            },
            {
              route: "version",
              text: "版本管理"
            },
            {
              route: "protocol",
              text: "协议配置"
            }
          ]
        }]
      }
    }
  },
  beforeMount(){
    let userRole = JSON.parse(localStorage.getItem('user')).userRoles;
    this.testMenuListData.menuList = this.testMenuListData.menuList.filter(item => {
      item.items = item.items.filter(itm => {
        let i ='';
        if (itm.route){
          i = `/${this.testMenuListData.baseRoute}/${itm.route}`;
        }else {
          i=`/${this.testMenuListData.baseRoute}`;
        }
        if (userRole.indexOf(i)>-1) return itm;
      })
      if (item.items.length > 0) return item
    })
  },
  methods: {
    onClick(event, pIndex, index) {
      console.log(event,pIndex,index)
    }
  }
}
</script>
